package view;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import ca.etsmtl.log730.lab3.model.Branch;
/*
 * JE SUIS LE MODELE DE REPRÉSENTATION EN JTABLE DES SUCCURSALES
 */
public class BranchTableModel extends AbstractTableModel {
	@Override
	public String getColumnName(int column) {
		if(column == 0) return "NOM";
		if(column == 1) return "MONTANT";
		return "";
	}

	private List<Branch> branches = new ArrayList<Branch>();
	public List<Branch> getBranches() {
		return branches;
	}

	public void setBranches(List<Branch> branches) {
		this.branches = branches;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -3202466305814576099L;

	@Override
	public int getColumnCount() {
		return 2;
	}

	@Override
	public int getRowCount() {
		return this.branches.size();
	}

	@Override
	public Object getValueAt(int x, int y) {
		Branch b = branches.get(x);
		if(y == 0) return b.getName();
		if(y == 1) return b.getAmount();
		return null;
	}

}
